package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.CollectArticleDao;
import com.guochenglang.www.pojo.CollectArticle;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 收藏文章表的Dao层
 *
 * @author GuoChenglang
 */
public class CollectArticleDaoImpl implements CollectArticleDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(CollectArticle.class);

    @Override
    public ArrayList<CollectArticle> collectArticleSelect(CollectArticle collectArticle) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectMax(TABLE, collectArticle);
    }

    @Override
    public ArrayList<CollectArticle> collectArticleSelectByLimit(int page, int num, CollectArticle conditions, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, conditions, order, mode);
    }

    @Override
    public int insertCollectArticle(CollectArticle collectArticle) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, collectArticle);
    }

    @Override
    public int deleteCollectArticle(CollectArticle collectArticle) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, collectArticle);
    }
}
